package com.hlhj.carview.aty

import android.widget.RadioButton
import com.hlhj.carview.BaseAty
import com.hlhj.carview.Iview.GetCashView
import com.hlhj.carview.R
import com.hlhj.carview.Toast
import com.hlhj.carview.bean.MyBaseBean
import com.hlhj.carview.presenter.GetCashPresenter
import com.hlhj.carview.utils.ToastUtil
import kotlinx.android.synthetic.main.aty_getcash.*
import kotlinx.android.synthetic.main.lo_pubhead.*

/**
 * Created by Never Fear   on 2019\1\11 0011.
Never More....
 */
class GetCashAty:BaseAty<GetCashView,GetCashPresenter>(), GetCashView {
    private var type=1

    override fun initView() {
        tvTittle.text="提现申请"

        val button = rgType.getChildAt(0) as RadioButton
        button.isChecked=true
        tv1.text="可提现金额 0 元"
    }
    override fun setResult(myBaseBean: MyBaseBean) {
        ToastUtil.toast("提现申请成功",this)
        setResult(-1)
        finish()
    }

    override fun logicStart() {
    }

    override fun setListener() {
        btGetCash.setOnClickListener {
            if (etAccount.text.toString().isEmpty()){
                ToastUtil.toast("请输入账号",this)
                return@setOnClickListener
            }
            if (type==0){
                ToastUtil.toast("请选择账户类型",this)
                return@setOnClickListener
            }
            if (etMoney.text.isEmpty()){
                ToastUtil.toast("请输入提现金额",this)
                return@setOnClickListener
            }
            if (etMoney.text.toString().toFloat()<100f){
                ToastUtil.toast("提现金额不能小于100",this)
                return@setOnClickListener
            }
            "您的金额暂时不足以提现哦".Toast()
//            presenter?.getcash(etAccount.text.toString(),type,etMoney.text.toString(),this)
        }
        btAll.setOnClickListener {
            etMoney.setText("0")
        }
        tv1.setOnClickListener {

        }
        rgType.setOnCheckedChangeListener { group, checkedId ->
            when(checkedId){
                R.id.rbWx->{
                    type=1
                }
                R.id.rbAli->{
                    type=2
                }
            }
        }
    }

    override fun bindView(): GetCashView {
        return this
    }

    override fun createPresenter(): GetCashPresenter {
        return GetCashPresenter()
    }

    override fun getContentID(): Int {
        return R.layout.aty_getcash
    }
}